﻿using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Markup;

namespace MediaBrowser.Gui.Converters
{
    /// <summary>
    /// Cette classe convertit une valeur object en un boolean pour savoir si l'object est null
    /// </summary>
    [ValueConversion(typeof(object), typeof(bool))]
    public class IsNullConverter : MarkupExtension, IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return (value == null);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new InvalidOperationException("IsNullConverter can only be used OneWay.");
        }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return new IsNullConverter();
        }

    }
}
